Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WhatsApp component #226

Merged
merged 14 commits into from
Aug 9, 2024

Conversation

AmeliaCelline
Copy link
Collaborator

@AmeliaCelline AmeliaCelline commented Jul 18, 2024

Because

  • We want to integrate WhatsApp component to VDP

This commit

TODO:

  • Send Text-Based Template Message
  • Send Media-Based Template Message
  • Send Location-Based Template Message
  • Send Authentication Template Message

For more information about sending template message, please go to: https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates )

For more information about sending messages, please go to: https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages

  • I don't implement all the possible type of messages because
  1. Too complex and make the UI very clustered
  2. I don't think those messages are frequently used.
  • I initially wanted to make send catalog template message task. However, sending catalog template requires a real phone number which is not connected to any other WhatsApp account. For now, I will be skipping send catalog template task since I don't have the necessary phone number to test it.
  • There is no read message task because in order to read/receive message, need to use webhook.

Here is a document to explain more about the component
https://docs.google.com/document/d/1mXM7GqRiTJAI-eRth5nEXpah5ADxuFmm3pz3m8Ua8ys/edit?usp=sharing

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 65.97938% with 264 lines in your changes missing coverage. Please review.

Project coverage is 42.25%. Comparing base (4aeae69) to head (b294a7c).
Report is 5 commits behind head on main.

Files Patch % Lines
application/whatsapp/v0/send_template_message.go 70.80% 103 Missing and 24 partials ⚠️
application/whatsapp/v0/send_message.go 68.97% 64 Missing and 21 partials ⚠️
application/whatsapp/v0/main.go 33.33% 29 Missing and 1 partial ⚠️
application/whatsapp/v0/client.go 0.00% 21 Missing ⚠️
store/store.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
+ Coverage   40.70%   42.25%   +1.55%     
==========================================
  Files         121      125       +4     
  Lines       11842    12618     +776     
==========================================
+ Hits         4820     5332     +512     
- Misses       6402     6620     +218     
- Partials      620      666      +46     
Flag Coverage Δ
unittests 42.25% <65.97%> (+1.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@chuang8511 chuang8511 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some points to be fixed.
And, some suggestions, please take a look and consider if you want to modify them

application/whatsapp/v0/config/tasks.json Outdated Show resolved Hide resolved
"title": "Header Type",
"type": "string"
},
"id-or-link": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm
The id is the image id in WhatsApp platform that users uploaded in WhatsApp. right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, user need to upload it through an API call. If you need more info: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#get-media-id

"TASK_SEND_MEDIA_MESSAGE",
"TASK_SEND_LOCATION_MESSAGE",
"TASK_SEND_CONTACT_MESSAGE",
"TASK_SEND_INTERACTIVE_CALL_TO_ACTION_URL_BUTTON_MESSAGE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question
I forgot the reason why we do not have read message from clients' chatroom or group chatroom. Is it related to OAuth?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We do not have read message because the only way to "read" message from clients is to actually receive those messages through the webhook endpoints we have set up. To sum it up, it is not possible to extract messages from a chatroom, and that we can only read when we receive it through webhook endpoints.
  • Regarding group chatroom, it is not possible to add the phone numbers registered in WhatsApp Business API to a group.

application/whatsapp/v0/client.go Outdated Show resolved Hide resolved
application/whatsapp/v0/send_message.go Outdated Show resolved Hide resolved
application/whatsapp/v0/send_message.go Show resolved Hide resolved
application/whatsapp/v0/send_message.go Outdated Show resolved Hide resolved
application/whatsapp/v0/send_message.go Outdated Show resolved Hide resolved
application/whatsapp/v0/send_template_message.go Outdated Show resolved Hide resolved
}

func (c *WhatsappClient) SendMessageAPI(req interface{}, resp interface{}, PhoneNumberID string) (interface{}, error) {
httpReq := c.httpclient.R().SetBody(req).SetResult(resp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question
you have used SetResult(resp), why do you still respond api_response?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you are right, I didn't notice it before. I will change it.

chuang8511
chuang8511 previously approved these changes Aug 9, 2024
Copy link
Member

@chuang8511 chuang8511 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chuang8511
Copy link
Member

chuang8511 commented Aug 9, 2024

sorry, I just tried to resolved conflict in web version. and I should rebase it.
I will merge this PR after all CIs pass.
image

@chuang8511 chuang8511 merged commit 28d0de8 into instill-ai:main Aug 9, 2024
6 checks passed
donch1989 pushed a commit that referenced this pull request Aug 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.25.0-beta](v0.24.0-beta...v0.25.0-beta)
(2024-08-13)


### Features

* add a hook to avoid we miss make document
([#244](#244))
([4c4531d](4c4531d))
* add elasticsearch component
([#211](#211))
([eb492ca](eb492ca))
* add Fireworks AI component
([#237](#237))
([0c40652](0c40652))
* add Groq component
([#269](#269))
([1401220](1401220))
* add mongodb component
([#198](#198))
([2cb550f](2cb550f))
* add qdrant component
([#271](#271))
([bd2b9e6](bd2b9e6))
* add weaviate component
([#246](#246))
([cb3e667](cb3e667))
* add WhatsApp component
([#226](#226))
([28d0de8](28d0de8))
* **artifact:** add artifact component
([#268](#268))
([dabf472](dabf472))
* **artifact:** add artifact component
([#275](#275))
([15fc0d2](15fc0d2))
* **document:** integrate pdf2md in document operator
([#277](#277))
([07360d1](07360d1))
* **groq, fireworksai:** take out the unsupported models from instill
credit ([#283](#283))
([8978acd](8978acd))
* make component ID accessible on IExecution
([#257](#257))
([dd63656](dd63656))
* **openai:** support `gpt-4o-2024-08-06` and structured output
([#280](#280))
([8bdaef7](8bdaef7))
* **sql:** add TASK_INSERT_MANY and fix sql query validation
([#252](#252))
([3a93cea](3a93cea))
* **text:** add tokenizer for cohere & new gpt-4o
([#276](#276))
([5d8cec3](5d8cec3))
* **text:** revert "add tokenizer for cohere & new gpt-4o
([#276](#276))"
([910a330](910a330))


### Bug Fixes

* **artifact:** add the description to remind users to add file
extension ([#281](#281))
([5ff5d7a](5ff5d7a))
* ignore bold case and add all line to result
([#272](#272))
([219c77e](219c77e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants