Tensor product and diagonal homomorphism on algebras I encounterd two questions as follows:

Suppose $S$ is an $R$-algebra with a diagonal homomorphism $\Delta:S \to S\otimes_R S$ of algebras. If $R$-algebras $A$ and $B$ are also left $S$-modules, show that $A\otimes_RB$ is also a left $S$-module.


Show the inverse, i.e. for given $R$-algebra $S$ and any $R$-algebras $A$ and $B$ which are simultaneously left $S$-modules such that $A\otimes_RB$ is also a left $S$-module, then there is a diagonal homomorphism  $\Delta:S \to S\otimes_R S$ of algebras.

Well, the first one is easy to conclude: for $r\otimes s\in S\otimes_R S$ and $a\otimes b\in A\otimes_RB$, we define
$$(r\otimes s)\cdot (a\otimes b)=ra\otimes sb$$
then the composition
$$S\otimes (A\otimes_RB)\xrightarrow{\Delta\otimes(id)}(S\otimes_RS)\otimes(A\otimes_RB)\to A\otimes_RB$$
defines the $S$-module structure on $A\otimes_RB$. (I hope I am right!)
But for the inverse,
If the product $S\otimes (A\otimes_RB)\to A\otimes_RB$ exists, then we need $A$ (being a left $S$-module ) to be also a right $S$-module, therefore there exist an anti homomorphism $\chi_A:S\to S$ (depends on $A$) such that
$$r\cdot \sum_{i=1}^n a_i\otimes b_i=\sum_{i=1}^n \chi_A(r)a_i\otimes rb_i$$
I stack here. I even don't know if I went in right way.
Thanks for attention.
 A: First of all, I suppose that your ring $R$ is commutative (otherwise, I would say that it is improper to speak about $R$-algebras and, moreover, I don't see why the tensor product of $R$-algebras should be an $R$-algebra again in general).
Secondly, I would suppose in addition that if $f : A \to A'$ and $g : B \to B'$ are left $S$-linear morphisms (not necessarily multiplicative or unital), then $f \otimes_R g$ is left $S$-linear as well (I am not sure that the second claim is true if this condition is not satisfied, even if I don't have a counterexample at hand right now). In particular, I am interested in the morphisms $\rho_a:S \to S, s\mapsto sa,$ for all $a \in S$.
Once said so, your idea to answer to question one is correct. Concerning the converse, you know that $S$ itself is an $R$-algebra which is also a left $S$-module in particular, whence you may consider the left $S$-module $\left(S \otimes_R S,\cdot\right)$ and define
$$\Delta(s) := s \cdot (1_S \otimes_R 1_S).$$
Set
$$s\cdot (1_S \otimes_R 1_S) := \sum_{(s)} s' \otimes_R s''.$$
It happens that $\Delta(1_S) = 1_S \cdot (1_S \otimes_R 1_S) = 1_S \otimes_R 1_S$, whence it is unital, and
$$\Delta(st) = st \cdot (1_S \otimes_R 1_S) = s \cdot (t \cdot (1_S \otimes_R 1_S)) = s \cdot \left(\sum_{(t)} t' \otimes_R t''\right) \\ = s \cdot \left(\sum_{(t)} \rho_{t'}(1_S) \otimes_R \rho_{t''}(1_S)\right) 
 = \left(\sum_{(t)} \rho_{t'} \otimes_R \rho_{t''}\right) \left(s \cdot \left(1_S \otimes_R 1_S\right)\right) \\ = \sum_{(s),(t)} s't' \otimes_R s''t'' = \Delta(s)\Delta(t),$$
whence it is multiplicative.
