# External chatbot - How to force messages order?

**URL:** <https://tiledesk.discourse.group/t/external-chatbot-how-to-force-messages-order/57>\
**Category:** Technical issue\
**Created:** [June 8, 2021, 5:38pm UTC](https://tiledesk.discourse.group/t/external-chatbot-how-to-force-messages-order/57 "2021-06-08T17:38:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://tiledesk.discourse.group/u/alex)\
**Post date:** [June 8, 2021, 5:38pm UTC](https://tiledesk.discourse.group/t/external-chatbot-how-to-force-messages-order/57/1 "2021-06-08T17:38:23Z")

</div>

Hi guys, I’m developing an external chatbot and everything works fine.  
I just noted that sometimes my messages do not arrive in the same order I sent them from my chatbot application.

Just to clarify, I used this tutorial to create my chatbot application:

> **[Hello World tutorial](https://developer.tiledesk.com/external-chatbot/connect-your-own-chatbot)**
>
> Connect your own chatbots to Tiledesk

I send messages like this:

let msg1 = {  
text: ‘First message’  
}  
let msg2 = {  
text: ‘Oldest message, is reordered’  
}  
}  
tdclient.sendMessage(msg1);  
tdclient.sendMessage(msg2);

What I experience is that sometimes I receive messages in opposite order, mesg2 before message 1.

There is a way to “force” the the same sending order?

---

<div class="post-metadata">

**Author:** ![andreasponziello](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@andreasponziello](https://tiledesk.discourse.group/u/andreasponziello)\
**Post date:** [June 8, 2021, 5:43pm UTC](https://tiledesk.discourse.group/t/external-chatbot-how-to-force-messages-order/57/2 "2021-06-08T17:43:54Z")

</div>

Hi Alex.

You can use the parameter **attributes.clienttimestamp** to force the message timestamp to your server-side timestamp.  
Example:

```auto
 let msg1 = {
    text: 'First message',
    attributes: {
      'clienttimestamp': Date.now()
    }
  }
  let msg2 = {
    text: 'Oldest message, is reordered',
    attributes: {
      'clienttimestamp': Date.now()
    }
  }
  tdclient.sendMessage(msg1);
  tdclient.sendMessage(msg2);

```

In this way, the Web Widget and all the other native Tiledesk Clients will reorder the messages based on the _clienttimestamp_ attributes of the single messages.

You can find here a Replit example on how to manually reorder the messages to demonstrate the _clienttimestamp_ property:

> **[tiledesk-client-timestamp-demo](https://replit.com/@tiledesk/tiledesk-client-timestamp-demo#index.js)**
>
> A Node.js repl by tiledesk
