# Working with messages between contacts using code

**URL:** <https://forum.communityhealthtoolkit.org/t/working-with-messages-between-contacts-using-code/2691>\
**Category:** Technical Support\
**Tags:** sms, rapidpro, messaging\
**Created:** [April 27, 2023, 7:37am UTC](https://forum.communityhealthtoolkit.org/t/working-with-messages-between-contacts-using-code/2691 "2023-04-27T07:37:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielmwakanema](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/danielmwakanema/32/2947_2.png) [@danielmwakanema](https://forum.communityhealthtoolkit.org/u/danielmwakanema)\
**Post date:** [April 27, 2023, 7:37am UTC](https://forum.communityhealthtoolkit.org/t/working-with-messages-between-contacts-using-code/2691/1 "2023-04-27T07:37:27Z")

</div>

Problem description:  
We have developed an app that is integrated with RapidPro to send automated messages to clients. We would like the automated messages sent from RapidPro to clients to also appear in the Messages tab. We want them to appear as being sent from the community health volunteer (CHV) to the client. This so that the CHV is able to make sense out of the messaging history.

We explored the following ways of doing this through RapidPro webhooks:

- POSTing to /api/sms and specifying “from” and “to” properties in the payload. This did not seem to work.
- Creating an sms\_message data record for the contact directly in CouchDB. This worked. However, we noted that since these automated messages will show up as new messages for the CHV, it would create spam and make it difficult to discern these automated messages from actual client interactions.

Where we need help:

- Alternatives to achieving this that may be easier and less complicated
- How to mark the sms\_message data record as already read so that we avoid spamming the CHV. This in the case that there are no better ways of achieving what we need.

---

<div class="post-metadata">

**Author:** ![niraj](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/niraj/32/1330_2.png) [@niraj](https://forum.communityhealthtoolkit.org/u/niraj)\
**Post date:** [April 29, 2023, 3:15am UTC](https://forum.communityhealthtoolkit.org/t/working-with-messages-between-contacts-using-code/2691/2 "2023-04-29T03:15:00Z")

</div>

Hi @danielmwakanema,

Welcome to the CHT Forum! It’s great to have you here.

sorry for the delay in response. Since, RapidPro is not a project we maintain so not sure but may be it will be more helpful to explore if there has been similar posts in community for RapidPro [here](https://community.rapidpro.io/rpcommunity/) to get more prompt response?

Hi @cliff and @kitsao I saw you have previously asked questions related to RapidPro. Do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![cliff](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/cliff/32/1638_2.png) [@cliff](https://forum.communityhealthtoolkit.org/u/cliff)\
**Post date:** [May 1, 2023, 10:52am UTC](https://forum.communityhealthtoolkit.org/t/working-with-messages-between-contacts-using-code/2691/3 "2023-05-01T10:52:05Z")

</div>

> [@danielmwakanema](#):
>
> POSTing to /api/sms and specifying “from” and “to” properties in the payload. This did not seem to work.

hello @danielmwakanema

you could try

```auto
@(json(object(
"id", run.uuid,
"from", replace(urns.tel, "tel:", ""),
"content", "AUTOMATED UPDATE : Client joined NIGHT message group"
)))

```
