1. Business Background
As a simple business scenario, end customers follow the official WeChat account of a car dealer, and then submit service requests to the dealer via WeChat. The service agents of the dealer could respond to the service requests, and the message will be posted to users in WeChat.
In this scenario, the end customers who follow the official WeChat account are created as individual customers in C4C, and service agents can reply to the service requests in C4C via Service Ticket.
- Customers need to build up an intermediary server to receive and forward message between WeChat server and C4C.
- The related API should have been provided by C4C.
- The integration scenario in this case is mostly based on web service (use soap as protocol) instead of OData service, because some of the OData services are not available yet.
- The scenario is based on HTML5 client not on RUI client.
- WeChat is configured as a Custom Channel Type.
4. Integration process
4.1 flow chart
4.2 Process description
a. Users follow the official account. Intermediary servers collect the user information and create user profile in C4C system.
b. Users create customer account via WeChat official account. Intermediary servers receive the request and call API provided by C4C to create individual customer in system.
c. Users create tickets via WeChat official account. Intermediary servers receive the request and call API provided by C4C to create ticket in system.
d. Administrator replies ticket in C4C. The message will be pushed to intermediary servers with the interface configured in C4C and then be posted to users.
4.3 Development list
a. Development of intermediary server
b. Interface configuration in C4C Back-end
c. H5 web page of official account
5.1 intermediary servers
5.1.1 path of event listening
|GET||Validate the connection with WeChat server|
|POST||Receive the message and event from WeChat official account|
|/c4c/wechat||POST||Receive the message from C4C|
|/getWXWebToken||POST||Get the token and openid of WeChat official account|
|/web/create||POST||Handle the create request from web page of WeChat official account|
|/web/update||POST||Handle the update request from web page of WeChat official account|
|/web/get||GET||Handle the read request from web page of WeChat official account|
5.1.2 Handle the token of official account API
The token is necessary when calling WeChat API.
Developer need to get the token via link: https://api.weixin.qq.com/cgi-bin/token? grant_type=client_credential&appid=APPID&secret=APPSECRET
Each token will be expired in 2 hours. If the new token is generated, old one will be expired at once. In order to avoid multiple users refresh token at the same time to cause the token expired again and again, we suggests that the token should be stored in server and refreshed every 2 hours. All the users get the token from server.
5.1.3 Validate the WeChat official account server
In the administration page of official account, complete the configuration as below:
When the configuration is saved, WeChat server will post the token and some other parameters to the configured path ‘/wechat’ with http get mode. In the intermediary server, the same token will be encrypted and compared with the signature to implement the connection.
The parameters received by intermediary server are as below:
a. Sort ‘token’, timestamp’, ‘nonce’ in lexicographical order;
b. Concatenate the three parameters into string and complete Algorithm encryption;
c. Compare the encrypted string with signature to identify the request is from WeChat official account.
5.1.4 Generate the customized user menu in official account
Call the API of WeChat official account with POST mode ( use https as protocol)
‘ACCESS_TOKEN’ is the token stored in server in previous steps. Detail please refer to
5.2 Configuration in C4C
- Create custom channel type
- Create mashup service
Create mashup service to interact with the intermediary server.
Url: <Your server address>/c4c/wechat
Other fields are filled as the screenshot.
- Create custom channel
Create new custom channel with the channel type created in previous step.
The custom channel is the representation of related official account in C4C.
Please fill the fields as screenshot.
- C4C API
It’s recommended to implement the interaction with OData service. But some interfaces must use web service instead (use SOAP as protocol) because not all related OData services are available. The related OData services are considered for future releases.
a. OData service
We provide standard OData service in C4C which contains several entities: https://<host_url>/sap/c4c/odata/v1/c4codata
Developer could handle CURD request with https://<host_url>/sap/c4c/odata/v1/c4codata/entityCollection
b. web service
Please configure and access the web service as below:
6. HTML5 client web page of WeChat official account
Please refer to sample code with detail.
Memo: You could consult the sample code for intermediary server implementation.