微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應

i042416發表於2020-09-26

文章系列目錄

In previous blog  Wechat development series 9 – Create C4C Social Media Message and Service within Wechat app it is already achieved that Wechat user can directly talk to the subscription account in Wechat app and a new Service Request ( and a social media message ) will automatically be created in C4C system under custom channel created for Wechat.

微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


With this message ID 59189 we can find its associated Service Request:


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


It comes very naturally that once a C4C agent replies this Service Request in the system, the reply will not only appear in C4C UI:


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應 微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


but also directly pushed to end user’s Wechat app:


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


Implementation detail

(1) Create a new Mashup service with type “REST Service”:


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


Maintain the following settings:


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


When the service request is replied in C4C, a json string will be sent to the url configured in this Mashup service (  wechatjerry.herokuapp.com  ) by a HTTP Post. The json string contains the ID of original social media message created when the end user sent the text to Wechat app in the beginning.

Assign this Mashup service to your custom channel for Wechat created in previous blog.


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


(2) React to the HTTP Post request in your nodejs server by adding a new route for url /fromc4c, which is configured in your Mashup service done in previous step.


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


The following logics are done in this module: (1) get social media message detail based on message ID from payload sent from C4C system (2) The social media user profile ID is stored as a field of message detail fetched from Step 1.

Get user profile detail data based on its ID. (3) The ID of Wechat user who has initially sent the text to C4C system is contained in social media user profile detail data. With this ID available now we can call module postMessageToUser to send the text maintained in C4C system to user’s Wechat app.

These three steps are done in another three separate modules:


微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":

微信開發系列之十 - 在SAP C4C接收微信傳送過來的服務請求回應


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2724270/,如需轉載,請註明出處,否則將追究法律責任。

相關文章