# Chat Bot Message Index Out Of Range

**URL:** <https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172>\
**Category:** App Marketplace\
**Created:** [February 1, 2019, 11:16pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172 "2019-02-01T23:16:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 1, 2019, 11:16pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/1 "2019-02-01T23:16:53Z")

</div>

After installing the Chatbot and running tests we encountered an error while trying to send a message. We cant figure out how we should send the message through node, we’ve tried with your rich text options and simple strings.

Also, we are now testing with a local host url redirect. What should type of url/server should we get for it to work on a production environment.

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [February 4, 2019, 5:11pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/2 "2019-02-04T17:11:35Z")

</div>

Hi @jorge.canavati,

Can you share with us the error that you are receiving and perhaps the full payload? Which message content are you using? To make sure your production environment, can you confirm if your publishable url is working?

Here is an example of the content that should work.  
content: {  
“head”: {  
“text”: “Ticket ZOOM-1000 Created”  
},  
“body”: [  
{  
“type”: “message”,  
“text”: “ZOOM-1000 New Bot Feature”,  
“editable”: true,  
“event\_id”: “Title\_Msg\_Edit”,  
“event”: “sendHttpMsg”  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 5, 2019, 9:42pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/3 "2019-02-05T21:42:07Z")

</div>

Also one more question, the bot seems to be installed on many of the users without any request to do so, it just installed automatically in their accounts and  
sent a “Hello” message. Is there any way in which I can disable this property so it can get just installed in my account for development and testing?

Best Regards,

---

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 6, 2019, 11:17pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/4 "2019-02-06T23:17:13Z")

</div>

This is the code and the reponse im using.

CODE:

const express = require(‘express’)  
const app = express()  
const config = require(’./config’);  
const request = require(‘request’);

app.get(’/’, (req, res) =\> {  
//this will check if the code parameter is in the url, if not the most likely case is that this is the user’s inital visit to oauth and we need to redirect them (Step 1)  
//if there is a code, it most likely means they were redirected here from zoom oauth screen  
if (req.query.code) {  
// Send bot message  
let url = ‘[https://zoom.us/oauth/token?grant\_type=client\_credentials&client\_id=](https://zoom.us/oauth/token?grant_type=client_credentials&client_id=)’ + config.clientID + ‘&client\_secret=’ + config.clientSecret;  
//STEP 3  
//we need to exchange the code for a oauth token  
request.post(url, function (error, response, body) {  
//the response should be a JSON payload  
body = JSON.parse(body);  
console.log(body);

```
         if (body.access_token) {
             //STEP 4 
            //we can now use the access token to make API calls
            /* 
                Send Bot Message /POST v2/im/chat/messages 
            */
            var options = { method: 'POST',
                            url: 'https://api.zoom.us/v2/im/chat/messages',
                            headers: { 
                                Authorization: 'Bearer ' + body.access_token,
                                'Content-Type': 'application/json' 
                            },
                            body: { 
                              robot_jid: 'XXXXXX@xmpp.zoom.us', //located in marketplace, bot JID 
                              to_jid: 'XXXXXXXXX', //group jid
                              account_id: 'XXXXXXXX', //user account ID
                              content: {
                                head: {
                                text: 'Ticket ZOOM-1000 Created'
                                },
                                body: [
                                {
                                type: 'message',
                                text: 'ZOOM-1000 New Bot Feature',
                                editable: true,
                                event_id: 'Title_Msg_Edit',
                                event: 'sendHttpMsg'
                                }
                                ]
                                }
                                 //message to be group  
                            },
                            json: true 
                        };
                     console.log(options);
                     request(options, function (error, response, body) {
                      if (error) throw new Error(error);
                       console.log(body);
                    });
         
        } else {
            //handle error, something went wrong
             console.log('something went wrong')
        }
     }).auth(config.clientID, config.clientSecret);
     return;
}
 //STEP 2
//no code provided, so redirect the user to get the code
res.redirect('https://zoom.us/oauth/authorize?response_type=code&client_id=' + config.clientID + '&redirect_uri=' + config.redirectUrl);

```

});  
app.listen(3000, () =\> console.log(‘Zoom chat bot sample app listening on port 3000!’))

Output:

C:…\zoom-bot-api-master\>node sendBotMessage.js

Zoom chat bot sample app listening on port 3000!  
{ access\_token:  
‘eyJhbGciOiJIUzUxMiJ9.eyJhdWQiOiJodHRwczovL29hdXRoLnpvb20udXMiLCJ2ZXIiOiIyLjAiLCJuYmYiOjE1NDkzOTE3NzcsImNsaWVudElkIjoiS1dBOElkOXZRMWE3aGd6Q1ZDcE9TUSIsImlzcyI6InVybjp6b29tOmNvbm5lY3Q6Y2xpZW50aWQ6S1dBOElkOXZRMWE3aGd6Q1ZDcE9TUSIsImVudiI6W251bGxdLCJleHAiOjE1NDkzOTUzNzcsInRva2VuVHlwZSI6ImNsaWVudF90b2tlbiIsImlhdCI6MTU0OTM5MTc3NywidXNlcklkIjoiQjJxV2RzYVdRT3VrcE5CRVBDQTdndyIsImp0aSI6ImI3MjRmYzZkLTJhNGItNGFmMS04OGMwLWM4OGNlMDZmZGY0MiJ9.mYn4XxYEwlhywcqr1fdRnHz0PsQl6I61fm94bc5BE8mD5sauKdpRa10UzAU54DIMEJZFgc7beH0yYiEPCjp7dw’,  
token\_type: ‘bearer’,  
expires\_in: 3599,  
scope:  
‘imgroup:read:admin imgroup:write:admin imchat:write:admin imchat:bot imchat:read:admin’ }  
{ method: ‘POST’,  
url: ‘[https://api.zoom.us/v2/im/chat/messages](https://api.zoom.us/v2/im/chat/messages)’,  
headers:  
{ Authorization:  
‘Bearer eyJhbGciOiJIUzUxMiJ9.eyJhdWQiOiJodHRwczovL29hdXRoLnpvb20udXMiLCJ2ZXIiOiIyLjAiLCJuYmYiOjE1NDkzOTE3NzcsImNsaWVudElkIjoiS1dBOElkOXZRMWE3aGd6Q1ZDcE9TUSIsImlzcyI6InVybjp6b29tOmNvbm5lY3Q6Y2xpZW50aWQ6S1dBOElkOXZRMWE3aGd6Q1ZDcE9TUSIsImVudiI6W251bGxdLCJleHAiOjE1NDkzOTUzNzcsInRva2VuVHlwZSI6ImNsaWVudF90b2tlbiIsImlhdCI6MTU0OTM5MTc3NywidXNlcklkIjoiQjJxV2RzYVdRT3VrcE5CRVBDQTdndyIsImp0aSI6ImI3MjRmYzZkLTJhNGItNGFmMS04OGMwLWM4OGNlMDZmZGY0MiJ9.mYn4XxYEwlhywcqr1fdRnHz0PsQl6I61fm94bc5BE8mD5sauKdpRa10UzAU54DIMEJZFgc7beH0yYiEPCjp7dw’,  
‘Content-Type’: ‘application/json’ },  
body:  
{ robot\_jid: ‘XXXXXX@xmpp.zoom.us’,  
to\_jid: ‘XXXXX’,  
account\_id: 'XXXXX,  
content: { head: [Object], body: [Array] } },  
json: true }  
{ message: ‘String index out of range: -1’, code: 500 }

---

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 11, 2019, 6:27pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/5 "2019-02-11T18:27:08Z")

</div>

Error still persist, any help will be appreciated.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [February 11, 2019, 7:57pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/6 "2019-02-11T19:57:54Z")

</div>

Hi @jorge.canavati,

Sorry for the delay, just wanted to let you know that we’re still troubleshooting your issue and will get back to you as soon as we find a workaround for you.

Thanks

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [February 11, 2019, 9:09pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/7 "2019-02-11T21:09:52Z")

</div>

Hi @jorge.canavati,

> [@jorge.canavati](#):
>
> Also one more question, the bot seems to be installed on many of the users without any request to do so, it just installed automatically in their accounts and  
> sent a “Hello” message. Is there any way in which I can disable this property so it can get just installed in my account for development and testing?

A workaround would be to create the bot on another test account of testing/developing purposes.

> [@jorge.canavati](#):
>
> content: { head: { text: ‘Ticket ZOOM-1000 Created’ }, body: [{ type: ‘message’, text: ‘ZOOM-1000 New Bot Feature’, editable: true, event\_id: ‘Title\_Msg\_Edit’, event: ‘sendHttpMsg’ }] } //message to be group }

I think you need to include double quotes “” for the property and value for the content object simliar to sample I gave earlier in the thread.

Let us know if that works.

---

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 12, 2019, 12:37am UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/8 "2019-02-12T00:37:50Z")

</div>

Did you meant something like this?

var options = { method: ‘POST’,  
url: ‘[https://api.zoom.us/v2/im/chat/messages](https://api.zoom.us/v2/im/chat/messages)’,  
headers: {  
Authorization: 'Bearer ’ + body.access\_token,  
‘Content-Type’: ‘application/json’  
},  
body: {  
robot\_jid: ‘v1tdfvixv3tcqmtweqnze66a@xmpp.zoom.us’, //located in marketplace, bot JID  
to\_jid: ‘fj1lWHcPSfi2bppKuoB-Ig’, //group jid  
account\_id: ‘fcN-RcaRRi-5PTFKtkjsLA’, //user account ID  
content: {  
“head”: {  
“text”: “Ticket ZOOM-1000 Created”  
},  
“body”: [  
{  
“type”: “message”,  
“text”: “ZOOM-1000 New Bot Feature”,  
“editable”: true,  
“event\_id”: “Title\_Msg\_Edit”,  
“event”: “sendHttpMsg”  
}  
]  
}  
//message to be group  
},  
json: true  
};  
console.log(options);  
request(options, function (error, response, body) {  
if (error) throw new Error(error);  
console.log(body);  
});

I Did tried it before and it still didnt work, same response from the server was achieved.

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [February 12, 2019, 1:45am UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/9 "2019-02-12T01:45:43Z")

</div>

Hi @jorge.canavati,

Can you try to do this in postman or a curl request? I wanted to make sure it’s not the code base that is somehow causing the error.

Thanks

---

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 13, 2019, 6:50pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/10 "2019-02-13T18:50:08Z")

</div>

Hi @michael_p.zoom, ive tried with the curl request example you guys have on the guide:

```auto
curl -X POST \
  https://api.zoom.us/v2/im/chat/messages \
  -H 'Authorization: Bearer xxxxxxxxxxxxx' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
	"robot_jid":"xxxxx@xmpp.zoom.us",
	"to_jid":"xxxxxx",
	"account_id": "xxxxxxxx",
	"content": {
    "head": {
      "text": "Ticket ZOOM-1000 Created"
    },
    "body": [
      {
        "type": "message",
        "text": "ZOOM-1000 New Bot Feature"
      }
    ]
  }
}'

```

I left it as it is but with our data instead of the “xxxxx”, i still get the same response:

{“message”:“String index out of range: -1”,“code”:500}

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/1X/ffcfd4a3cd320a537f87362d710756b54b94d6e0.png)

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [February 13, 2019, 9:31pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/11 "2019-02-13T21:31:35Z")

</div>

Hi @jorge.canavati,

Let me expedite this issue to our Engineers, to see why the error is happening. I’ll follow back up with you as soon as possible.

Thanks

---

<div class="post-metadata">

**Author:** ![jorge.canavati](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jorge.canavati](https://devforum.zoom.us/u/jorge.canavati)\
**Post date:** [February 15, 2019, 10:23pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/13 "2019-02-15T22:23:15Z")

</div>

Ive tried by even testing in your marketplace api description. Still wont work.

 ![zoom%20chat](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/1X/c0c8444a5722857fe4972dfb237b7083434ad783.jpeg)

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [February 20, 2019, 7:17pm UTC](https://devforum.zoom.us/t/chat-bot-message-index-out-of-range/3172/14 "2019-02-20T19:17:33Z")

</div>

Hi @jorge.canavati,

I recently tested the below curl request using the same content payload and it worked for me.

curl -X POST   
[https://api.zoom.us/v2/im/chat/messages](https://api.zoom.us/v2/im/chat/messages)   
-H ‘Authorization: Bearer XXXX’   
-H ‘Cache-Control: no-cache’   
-H ‘Content-Type: application/json’   
-H ‘Postman-Token: XXXXX’   
-d '{  
“robot\_jid”:"1xbim5frtyim5cgq@xmpp.zoom.us",  
“to\_jid”:"1eb8f3e7a5c52@conference.xmpp.zoom.us",  
“account\_id”: “qsmdmkg”,  
“content”: {  
“head”: {  
“text”: “Ticket ZOOM-1000 Created”  
},  
“body”: [  
{  
“type”: “message”,  
“text”: “ZOOM-1000 New Bot Feature”  
}  
]  
}  
}

Can you send us an email at [developersupport@zoom.us](mailto:developersupport@zoom.us) with your account ID, robot\_jid, and to\_jid from there we’ll do some more testing by end of the day to see why this error is occurring on your end.

Thanks
